import javax.swing.JOptionPane;

public class Simulator {
	/**
	 * @modulename Simulator
	 * @description This class handles the hardware simulation of the TRESSEL
	 *              machine.
	 * @callsequence Simulator.execute();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, began implementing Simulator
	 *         <li>Nick, 11/19/09, continued work on Simulator
	 *         <li>Nick, 11/23/09, added in methods for display operation and
	 *         debug bit on
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	// memory is represented as an array of string. each position in the array
	// represents a word of memory.
	public static String[] memory = new String[4096];

	// the accumulator is represented as an integer
	public static Integer accumulator = 0;

	// the base register is represented as an integer
	public static Integer base = 0;

	// the index register is represented as an integer
	public static Integer index = 0;

	// the alternative register is represented as an integer
	public static Integer alternative = 0;

	// the parameter list address register is represented as an integer
	public static Integer parameterListAddress = 0;

	// the status register is represented as an array of characters
	public static char[] status = { '0', '0', '0', '0', '0', '0', '0', '0',
			'0', '0', '0', '0', '0', '0', '0', '0' };

	// status register field constants
	public static final int addOverflow = 0;
	public static final int subOverflow = 1;
	public static final int mulOverflow = 2;
	public static final int divOverflow = 3;
	public static final int divByZero = 4;
	public static final int shiftError = 5;
	public static final int rotateError = 6;
	public static final int addrBeforeStart = 7;
	public static final int addrAfterEnd = 8;
	public static final int jump = 9;

	// the location counter register is represented as an integer
	public static Integer location = 0;

	// next instruction register is represented as an integer
	public static Integer nextInstruction = 0;

	// the effective address register is represented as an integer
	public static Integer effectiveAddress = 0;

	// the instruction word register is represented as a string
	public static String instructionWord = new String();

	// the instruction parsed into binary fields is represented by an array of
	// strings
	public static String[] parsedInstruction = new String[7];

	// parsed instruction field constants
	public static final int opcode = 0;
	public static final int ir = 1;
	public static final int ar = 2;
	public static final int br = 3;
	public static final int debug = 4;
	public static final int addrflgs = 5;
	public static final int address = 6;

	/**
	 * @modulename execute
	 * @description this method executes the module in the load file
	 * @callsequence Simulator.execute()
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void execute() {

		// initialize memory
		initializeMemory();

		// load module
		loadModule();

		// display memory
		displayMemory(LoadFile.returnModuleName()
				+ " has been successfully loaded to memory. Click \"OK\" to continue.");

		// get load address
		location = LoadFile.returnStartAddress();

		// next instruction is at location
		nextInstruction = location;

		// get the first instruction
		instructionWord = memory[nextInstruction];

		// parse the first instruction
		parsedInstruction = parseInstruction(instructionWord);

		// calculate the effective address
		calculateEffectiveAddress();

		// display start information dump
		informationDump("See output log for START information dump. Click \"OK\" to continue.");

		do { // while the next instruction is not halt

			// DEBUG dialog
			if (parsedInstruction[debug].contains("1")) {
				// output debug display
				informationDump("See output log for DEBUG (BEFORE) information dump. Click \"OK\" to continue.");
			}

			// execute instruction
			executeInstruction();

			if (location < LoadFile.returnLoadAddress()) {
				status[addrBeforeStart] = '1';
			} else if (location > (LoadFile.returnLoadAddress()
					+ LoadFile.returnModuleLength() - 1)) {
				status[addrAfterEnd] = '1';
			}

			// DEBUG dialog
			if (parsedInstruction[debug].contains("1")) {
				// output debug display
				informationDump("See output log for DEBUG (AFTER) information dump. Click \"OK\" to continue.");
			}

			if ((!(parsedInstruction[opcode].contains("101010")))) {
				// if the instruction did not set the jump bit...
				if (status[jump] != '1') {
					// increment location counter
					location++;
				}

				if (location != LoadFile.returnLoadAddress()
						+ LoadFile.returnModuleLength()) {
					// if the location will not cause an array out of bounds
					// error...
					if (location >= 0 && location <= 4095) {
						// next instruction is at location
						nextInstruction = location;

						// load next instruction to instruction word register
						instructionWord = memory[nextInstruction];

						// parse the next instruction
						parsedInstruction = parseInstruction(memory[nextInstruction]);

						// calculate effective address
						calculateEffectiveAddress();

						// reset status register
						status = "0000000000000000".toCharArray();
					} else {
						// HALT 99
						parsedInstruction[opcode] = "101010";
						parsedInstruction[address] = "00001100011";
					}
				}
			}
		} while ((!(parsedInstruction[opcode].contains("101010")))
				&& (location < LoadFile.returnLoadAddress()
						+ LoadFile.returnModuleLength()));
		
		if (parsedInstruction[opcode].contains("101010")) {
			
			JOptionPane.showMessageDialog(null, "Module has reached HALT "
					+ Integer.parseInt(parsedInstruction[address], 2) + ".");

			if (parsedInstruction[address].contains("00001100011")) {
				JOptionPane
						.showMessageDialog(
								null,
								"ERROR: "
										+ LoadFile.returnModuleName()
										+ " attempted to jump outside of the valid memory range.");
			} else if (parsedInstruction[address].contains("00001100010")) {
				JOptionPane
						.showMessageDialog(
								null,
								"ERROR: "
										+ LoadFile.returnModuleName()
										+ " attempted to write to memory outside of the valid memory range.");
			}
		} else {
			JOptionPane.showMessageDialog(null, "Module simulation complete.");
		}

		finalizeMemory();

		displayMemory(LoadFile.returnModuleName()
				+ " has finished execution. Click \"OK\" to continue.");

		informationDump("See output log for END information dump. Click \"OK\" to continue.");
	}

	/**
	 * @modulename initializeMemory
	 * @description this method initializes all locations in memory with
	 *              "A80063" (HALT 99)
	 * @callsequence initializeMemory()
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void initializeMemory() {
		// fill memory with HALT 99
		for (int i = 0; i < memory.length; i++) {
			memory[i] = "A80063";
		}
	}

	/**
	 * @modulename loadModule
	 * @description this method loads the module in the load file into the
	 *              memory array
	 * @callsequence loadModule()
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void loadModule() {
		Main2.appendDebugText("Loading " + LoadFile.returnModuleName() + "...");
		for (int i = 0; i < LoadFile.returnModuleLength(); i++) {
			Main2.appendDebugText("Loading "
					+ LoadFile.returnInstructionCode(i
							+ LoadFile.returnLoadAddress())
					+ " from module "
					+ LoadFile.returnInstructionModuleName(i
							+ LoadFile.returnLoadAddress())
					+ " to memory location "
					+ getHexString(i + LoadFile.returnLoadAddress()).substring(
							3) + "...");

			memory[i + LoadFile.returnLoadAddress()] = LoadFile
					.returnInstructionCode(i);

			Main2.appendDebugText("Memory["
					+ getHexString(i + LoadFile.returnLoadAddress()).substring(
							3) + "]: " + memory[i]);
		}

		Main2.appendDebugText(LoadFile.returnModuleName()
				+ " has been successfully loaded to memory." + Main.newline);
	}

	/**
	 * @modulename displayMemory
	 * @description This method displays the contents of the memory array and
	 *              outputs a message.
	 * @callsequence displayMemory(String displayDialog)
	 * @inparam (String) displayDialog: the message you want to display to the
	 *          user
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void displayMemory(String displayDialog) {
		Main2.appendDebugText("Memory Matrix:");
		for (int i = 0; i < memory.length; i = i + 8) {
			Main2.appendDebugText("Memory[" + getHexString(i).substring(3)
					+ "-" + getHexString(i + 7).substring(3) + "]:\t"
					+ memory[i] + "\t" + memory[i + 1] + "\t" + memory[i + 2]
					+ "\t" + memory[i + 3] + "\t" + memory[i + 4] + "\t"
					+ memory[i + 5] + "\t" + memory[i + 6] + "\t"
					+ memory[i + 7]);
		}
		JOptionPane.showMessageDialog(null, displayDialog);
		Main2.appendDebugText(Main.newline);
	}

	/**
	 * @modulename displayMemory
	 * @description This method displays the contents of the memory array
	 *              between two given addresses
	 * @callsequence displayMemory(int low, int high)
	 * @inparam (int) low: low address, (int) high: high address
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void displayMemory(int low, int high) {
		for (int i = low; i <= high; i = i + 8) {
			Main2.appendDebugText("Memory[" + getHexString(i).substring(3)
					+ "-" + getHexString(i + 7).substring(3) + "]:\t"
					+ memory[i] + "\t" + memory[i + 1] + "\t" + memory[i + 2]
					+ "\t" + memory[i + 3] + "\t" + memory[i + 4] + "\t"
					+ memory[i + 5] + "\t" + memory[i + 6] + "\t"
					+ memory[i + 7]);
		}
		Main2.appendDebugText(Main.newline);
	}

	/**
	 * @modulename finalizeMemory
	 * @description This method finalizes the contents of the memory array by
	 *              adding leading zeros memory locations that are less than 24
	 *              bits.
	 * @callsequence finalizeMemory()
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void finalizeMemory() {

		// make sure each location in memory is 3 bytes
		for (int i = 0; i < memory.length; i++) {

			// if too big remove extra bytes. this should not happen but just to
			// be safe...
			while (memory[i].length() > 6) {
				Main2.appendDebugText("WARNING: Memory overflow at location "
						+ i + ".");
				memory[i] = memory[i].substring(1);
			}
			// if too small add zeros
			while (memory[i].length() > 6) {
				Main2.appendDebugText("WARNING: Memory underflow at location "
						+ i + ".");
				memory[i] = "0" + memory[i];
			}
		}
	}

	public static void informationDump(String displayDialog) {
		Main2.appendDebugText("Accumulator:\t\t\t\t"
				+ getHexString(accumulator));
		Main2.appendDebugText("Base Register:\t\t\t\t" + "  "
				+ getHexString(base).substring(2));
		Main2.appendDebugText("Index Register:\t\t\t\t" + "  "
				+ getHexString(index).substring(2));
		Main2.appendDebugText("Alternative Register:\t\t\t"
				+ getHexString(alternative));
		Main2.appendDebugText("Parameter List Address Register:\t" + "  "
				+ getHexString(parameterListAddress).substring(2));
		Main2.appendDebugText("Status Register:\t\t\t" + "  "
				+ binaryToHex(new String(status)).substring(2));
		Main2.appendDebugText("Location Counter Register:\t\t" + "   "
				+ getHexString(location).substring(3));
		Main2.appendDebugText("Next Instruction Register:\t\t"
				+ getHexString(nextInstruction));
		Main2.appendDebugText("Effective Address Register:\t\t" + "  "
				+ getHexString(effectiveAddress).substring(2));
		Main2.appendDebugText("Instruction Word Register:\t\t"
				+ instructionWord);
		Main2.appendDebugText("Instruction as binary:\t\t\t"
				+ parsedInstruction[opcode] + " " + parsedInstruction[ir] + " "
				+ parsedInstruction[ar] + " " + parsedInstruction[br] + " "
				+ parsedInstruction[debug] + " " + parsedInstruction[addrflgs]
				+ " " + parsedInstruction[address]);
		Main2.appendDebugText("Memory[effaddr]:\t\t\t"
				+ memory[effectiveAddress]);
		JOptionPane.showMessageDialog(null, displayDialog);
		Main2.appendDebugText(Main.newline);
	}

	/**
	 * @modulename parseInstruction
	 * @description This method parsed a HEX encoded instruction into 7 binary
	 *              fields (opcode, ir, ar, br, debug, addrflags, and address)
	 * @callsequence parseInstruction(String instruction)
	 * @inparam (String) instruction: this is the HEX encoded instruction
	 * @outparam (String []): this is the result of parsing the instruction into
	 *           the binary fields
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static String[] parseInstruction(String instruction) {
		String[] parsedInstruction = new String[7];

		instruction = hexToBinary(instruction);

		// opcode is first six bits
		parsedInstruction[opcode] = instruction.substring(0, 6);

		// IR flag is seventh bit
		parsedInstruction[ir] = instruction.substring(6, 7);

		// AR flag is eight bit
		parsedInstruction[ar] = instruction.substring(7, 8);

		// BR bit is ninth bit
		parsedInstruction[br] = instruction.substring(8, 9);

		// debug bit is tenth bit
		parsedInstruction[debug] = instruction.substring(9, 10);

		// address flags are the eleventh through thirteenth bits
		parsedInstruction[addrflgs] = instruction.substring(10, 13);

		// address is the remaining eleven bits
		parsedInstruction[address] = instruction.substring(13, 24);

		return parsedInstruction;
	}

	/**
	 * @modulename executeInstruction
	 * @description This method executes the current instruction in the
	 *              instruction word register
	 * @callsequence executeInstruction()
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void executeInstruction() {

		switch (Integer.parseInt(parsedInstruction[opcode], 2)) {

		case 0:
			callLDAC();
			break;
		case 1:
			callSTAC();
			break;
		case 2:
			callLDIR();
			break;
		case 3:
			callSTIR();
			break;
		case 4:
			callLDAR();
			break;
		case 5:
			callSTAR();
			break;
		case 6:
			callLDBR();
			break;
		case 7:
			callSTBR();
			break;
		case 8:
			callADDAC();
			break;
		case 9:
			callSUBAC();
			break;
		case 10:
			callMULAC();
			break;
		case 11:
			callDIVAC();
			break;
		case 12:
			callADDIR();
			break;
		case 13:
			callSUBIR();
			break;
		case 14:
			callMULIR();
			break;
		case 15:
			callDIVIR();
			break;
		case 16:
			callANDAC();
			break;
		case 17:
			callORAC();
			break;
		case 18:
			callLANDAC();
			break;
		case 19:
			callLORAC();
			break;
		case 20:
			callABSAC();
			break;
		case 21:
			callANDIR();
			break;
		case 22:
			callORIR();
			break;
		case 23:
			callLANDIR();
			break;
		case 24:
			callLORIR();
			break;
		case 25:
			callANDSR();
			break;
		case 26:
			callORSR();
			break;
		case 27:
			callABSIR();
			break;
		case 28:
			callSLAAC();
			break;
		case 29:
			callSRAAC();
			break;
		case 30:
			callSLLAC();
			break;
		case 31:
			callSRLAC();
			break;
		case 32:
			callRROTAC();
			break;
		case 33:
			callLROTAC();
			break;
		case 34:
			callSLAIR();
			break;
		case 35:
			callSRAIR();
			break;
		case 36:
			callSLLIR();
			break;
		case 37:
			callSRLIR();
			break;
		case 38:
			callRROTIR();
			break;
		case 39:
			callLROTIR();
			break;
		case 40:
			callLDNAC();
			break;
		case 42:
			callHALT();
			break;
		case 44:
			callJMPPRLT();
			break;
		case 45:
			callJMPSRGT();
			break;
		case 46:
			callJMPSREQ();
			break;
		case 47:
			callJMPSRLT();
			break;
		case 48:
			callJMP();
			break;
		case 49:
			callJMPACGT();
			break;
		case 50:
			callJMPACEQ();
			break;
		case 51:
			callJMPACLT();
			break;
		case 52:
			callJMPIRGT();
			break;
		case 53:
			callJMPIREQ();
			break;
		case 54:
			callJMPIRLT();
			break;
		case 55:
			callDISPLAY();
			break;
		case 56:
			callREADNUM();
			break;
		case 57:
			callREADSTR();
			break;
		case 58:
			callWRITENUM();
			break;
		case 59:
			callWRITESTR();
			break;
		case 60:
			callLDACADR();
			break;
		case 61:
			callLDIRADR();
			break;
		case 62:
			callLDBRADR();
			break;
		case 63:
			callLDPR();
			break;
		default:
			JOptionPane.showMessageDialog(null, "ERROR: Undefined instruction at location "
					+ getHexString(location).substring(3)
					+ ". This instruction will not be executed.");
			break;
		}
	}

	/**
	 * @modulename calculateEffectiveAddress
	 * @description this method calculates the effective memory address and
	 *              stores in in the effective memory address register
	 * @callsequence Simulator.calculateEffectiveAddress()
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void calculateEffectiveAddress() {
		effectiveAddress = Integer.parseInt(parsedInstruction[address], 2);

		// if the address is not an actual value...
		if (!parsedInstruction[addrflgs].contains("111")) {

			// add ir if ir is on
			if (parsedInstruction[ir].contains("1")) {
				effectiveAddress += index;
			}

			// add ar if ar is on (not possible with current implementation but
			// what the hell...)
			if (parsedInstruction[ar].contains("1")) {
				JOptionPane.showMessageDialog(null, "WARNING: Alterative register in use bit is turned on for instruction at location " + getHexString(location).substring(3) + ".");
				effectiveAddress += alternative;
			}

			// if it's relative to base add the base register...
			if (parsedInstruction[addrflgs].contains("001")) {
				effectiveAddress += base;
			}

			// if it's indirect get the address from memory...
			else if (parsedInstruction[addrflgs].contains("010")) {
				effectiveAddress = getDecimalValue(memory[effectiveAddress]);
			}

			// if it's indirect and relative to base add the base register then
			// get the address from memory...
			else if (parsedInstruction[addrflgs].contains("011")) {
				effectiveAddress += base;
				effectiveAddress = getDecimalValue(memory[effectiveAddress]);
			}
		}
	}

	public static boolean effectiveAddressCheck() {
		// make sure the effective address wont be an array out of
		// bounds error...
		if ((effectiveAddress < 0 || effectiveAddress > 4095)) {

			JOptionPane
					.showMessageDialog(
							null,
							"The instruction at location "
									+ getHexString(location).substring(3)
									+ " has an effective address outside of the range of memory. It will not be executed. Click \"OK\" to continue.");

			return false;
		}

		return true;
	}

	/**
	 * @modulename callLDAC
	 * @description (AC)=c(memory(effadd))
	 * @callsequence Simulator.callLDAC();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callLDAC() {
		// load the AC with the contents of the effective address
		accumulator = getDecimalValue(memory[effectiveAddress]);
	}

	/**
	 * @modulename callSTAC
	 * @description c(memory(effadd))=AC
	 * @callsequence Simulator.callSTAC();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callSTAC() {
		if (effectiveAddressCheck()) {
			if (effectiveAddress < LoadFile.returnLoadAddress()
					|| effectiveAddress > (LoadFile.returnLoadAddress()
							+ LoadFile.returnModuleLength() - 1)) {
				// HALT 98
				parsedInstruction[opcode] = "101010";
				parsedInstruction[address] = "00001100010";
			} else {
				memory[effectiveAddress] = getHexString(accumulator);
			}
		}
	}

	/**
	 * @modulename callLDIR
	 * @description c(IR)=c(memory(effadd))
	 * @callsequence Simulator.callLDIR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callLDIR() {
		if (effectiveAddressCheck()) {
			index = getDecimalValue(memory[effectiveAddress]);
		}
	}

	/**
	 * @modulename callSTIR
	 * @description c(memory(effadd))=IR
	 * @callsequence Simulator.callSTIR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callSTIR() {
		if (effectiveAddressCheck()) {
			if (effectiveAddress < LoadFile.returnLoadAddress()
					|| effectiveAddress > (LoadFile.returnLoadAddress()
							+ LoadFile.returnModuleLength() - 1)) {
				// HALT 98
				parsedInstruction[opcode] = "101010";
				parsedInstruction[address] = "00001100010";
			} else {
				memory[effectiveAddress] = getHexString(index);
			}
		}
	}

	/**
	 * @modulename callLDAR
	 * @description c(AR)=c(memory(effadd))
	 * @callsequence Simulator.callLDAR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callLDAR() {
		if (effectiveAddressCheck()) {
			alternative = getDecimalValue(memory[effectiveAddress]);
		}
	}

	/**
	 * @modulename callSTAR
	 * @description c(memory(effadd))=AR
	 * @callsequence Simulator.callSTAR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callSTAR() {
		if (effectiveAddressCheck()) {
			if (effectiveAddress < LoadFile.returnLoadAddress()
					|| effectiveAddress > (LoadFile.returnLoadAddress()
							+ LoadFile.returnModuleLength() - 1)) {
				// HALT 98
				parsedInstruction[opcode] = "101010";
				parsedInstruction[address] = "00001100010";
			} else {
				memory[effectiveAddress] = getHexString(alternative);
			}
		}
	}

	/**
	 * @modulename callLDBR
	 * @description c(BR)=current memory address
	 * @callsequence Simulator.callLDBR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callLDBR() {
		if (effectiveAddressCheck()) {
			base = getDecimalValue(memory[effectiveAddress]);
		}
	}

	/**
	 * @modulename callSTBR
	 * @description c(memory(effadd))=BR
	 * @callsequence Simulator.callSTBR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callSTBR() {
		if (effectiveAddressCheck()) {
			if (effectiveAddress < LoadFile.returnLoadAddress()
					|| effectiveAddress > (LoadFile.returnLoadAddress()
							+ LoadFile.returnModuleLength() - 1)) {
				// HALT 98
				parsedInstruction[opcode] = "101010";
				parsedInstruction[address] = "00001100010";
			} else {
				memory[effectiveAddress] = getHexString(base);
			}
		}
	}

	/**
	 * @modulename callADDAC
	 * @description c(AC)=c(AC)+c(mem(effadd))
	 * @callsequence Simulator.callADDAC();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callADDAC() {
		if (effectiveAddressCheck()) {
			int result = accumulator
					+ getDecimalValue(memory[effectiveAddress]);
			if (result > 8388607 || result < -8388608) {
				JOptionPane.showMessageDialog(null,
						"ERROR: Addition over flow occurred at location "
								+ getHexString(location).substring(3)
								+ ". This operation will not be performed.");
				status[addOverflow] = '1';
			} else {
				accumulator = result;
			}
		}
	}

	/**
	 * @modulename callSUBAC
	 * @description c(AC)=c(AC)-c(mem(effadd))
	 * @callsequence Simulator.callSUBAC();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callSUBAC() {
		if (effectiveAddressCheck()) {
			int result = accumulator
					- getDecimalValue(memory[effectiveAddress]);
			if (result > 8388607 || result < -8388608) {
				JOptionPane.showMessageDialog(null,
						"ERROR: Subtraction over flow occurred at location "
								+ getHexString(location).substring(3)
								+ ". This operation will not be performed.");
				status[subOverflow] = '1';
			} else {
				accumulator = result;
			}
		}
	}

	/**
	 * @modulename callMULAC
	 * @description c(AC)=c(AC)*c(mem(effadd))
	 * @callsequence Simulator.callMULAC();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callMULAC() {
		if (effectiveAddressCheck()) {
			// there is an error here on purpose so i remember where i need to
			// start when i come back
			int result = accumulator
					+ getDecimalValue(memory[effectiveAddress]);
			if (result > 8388607 || result < -8388608) {
				JOptionPane.showMessageDialog(null,
						"ERROR: Multiplication over flow occurred at location "
								+ getHexString(location).substring(3)
								+ ". This operation will not be performed.");
				status[mulOverflow] = '1';
			} else {
				accumulator = result;
			}
		}
	}

	/**
	 * @modulename callDIVAC
	 * @description c(AC)=c(AC)/c(mem(effadd))
	 * @callsequence Simulator.callDIVAC();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callDIVAC() {
		if (effectiveAddressCheck()) {
			int result = 0;

			if (getDecimalValue(memory[effectiveAddress]) == 0) {
				JOptionPane.showMessageDialog(null,
						"ERROR: Division by zero occurred at location "
								+ getHexString(location).substring(3)
								+ ". This operation will not be performed.");
				status[divByZero] = '1';
			} else {
				result = accumulator
						/ getDecimalValue(memory[effectiveAddress]);
				if (result > 8388607 || result < -8388608) {
					JOptionPane
							.showMessageDialog(
									null,
									"ERROR: Division over flow occurred at location "
											+ getHexString(location).substring(
													3)
											+ ". This operation will not be performed.");
					status[divOverflow] = '1';
				} else {
					accumulator = result;
				}
			}
		}
	}

	/**
	 * @modulename callADDIR
	 * @description c(IR)=c(IR)+c(mem(effadd))
	 * @callsequence Simulator.callADDIR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callADDIR() {
		if (effectiveAddressCheck()) {
			int result = index + getDecimalValue(memory[effectiveAddress]);
			if (result > 8388607 || result < -8388608) {
				JOptionPane.showMessageDialog(null,
						"ERROR: Addition over flow occurred at location "
								+ getHexString(location).substring(3)
								+ ". This operation will not be performed.");
				status[addOverflow] = '1';
			} else {
				index = result;
			}
		}
	}

	/**
	 * @modulename callSUBIR
	 * @description c(IR)=c(IR)-c(mem(effadd))
	 * @callsequence Simulator.callSUBIR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callSUBIR() {
		if (effectiveAddressCheck()) {
			int result = index - getDecimalValue(memory[effectiveAddress]);
			if (result > 8388607 || result < -8388608) {
				JOptionPane.showMessageDialog(null,
						"ERROR: Substraction over flow occurred at location "
								+ getHexString(location).substring(3)
								+ ". This operation will not be performed.");
				status[subOverflow] = '1';
			} else {
				index = result;
			}
		}
	}

	/**
	 * @modulename callMULIR
	 * @description c(IR)=c(IR)*c(mem(effadd))
	 * @callsequence Simulator.callMULIR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callMULIR() {
		if (effectiveAddressCheck()) {
			int result = index * getDecimalValue(memory[effectiveAddress]);
			if (result > 8388607 || result < -8388608) {
				JOptionPane.showMessageDialog(null,
						"ERROR: Multiplication over flow occurred at location "
								+ getHexString(location).substring(3)
								+ ". This operation will not be performed.");
				status[mulOverflow] = '1';
			} else {
				index = result;
			}
		}
	}

	/**
	 * @modulename callDIVIR
	 * @description c(IR)=c(IR)/c(mem(effadd))
	 * @callsequence Simulator.callDIVIR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callDIVIR() {
		if (effectiveAddressCheck()) {
			int result = 0;

			if (getDecimalValue(memory[effectiveAddress]) == 0) {
				JOptionPane.showMessageDialog(null,
						"ERROR: Division by zero occurred at location "
								+ getHexString(location).substring(3)
								+ ". This operation will not be performed.");
				status[divByZero] = '1';
			} else {
				result = index / getDecimalValue(memory[effectiveAddress]);
				if (result > 8388607 || result < -8388608) {
					JOptionPane
							.showMessageDialog(
									null,
									"ERROR: Division over flow occurred at location "
											+ getHexString(location).substring(
													3)
											+ ". This operation will not be performed.");
					status[divOverflow] = '1';
				} else {
					index = result;
				}
			}
		}
	}

	/**
	 * @modulename callANDAC
	 * @description c(AC)=c(AC) AND c(mem(effadd))
	 * @callsequence Simulator.callANDAC();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callANDAC() {
		if (effectiveAddressCheck()) {
			accumulator = and(accumulator,
					getDecimalValue(memory[effectiveAddress]));
		}
	}

	/**
	 * @modulename callORAC
	 * @description c(AC)=c(AC) OR c(mem(effadd))
	 * @callsequence Simulator.callORAC();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callORAC() {
		if (effectiveAddressCheck()) {
			accumulator = or(accumulator,
					getDecimalValue(memory[effectiveAddress]));
		}
	}

	/**
	 * @modulename callLANDAC
	 * @description c(AC)=c(AC) LAND c(mem(effadd))
	 * @callsequence Simulator.callLANDAC();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callLANDAC() {
		if (effectiveAddressCheck()) {
			accumulator = land(accumulator,
					getDecimalValue(memory[effectiveAddress]));
		}
	}

	/**
	 * @modulename callLORAC
	 * @description c(AC)=c(AC) LOR c(mem(effadd))
	 * @callsequence Simulator.callLORAC();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callLORAC() {
		if (effectiveAddressCheck()) {
			accumulator = lor(accumulator,
					getDecimalValue(memory[effectiveAddress]));
		}
	}

	/**
	 * @modulename callABSAC
	 * @description c(AC)=|c(AC)|
	 * @callsequence Simulator.callABSAC();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callABSAC() {
		int result = abs(accumulator);

		if (result > 8388607 || result < -8388608) {
			JOptionPane.showMessageDialog(null,
					"ERROR: Multiplication over flow occurred at location "
							+ getHexString(location).substring(3)
							+ ". This operation will not be performed.");
			status[mulOverflow] = '1';
		} else {
			accumulator = result;
		}
	}

	/**
	 * @modulename callANDIR
	 * @description c(IR)=c(IR) AND c(mem(effadd))
	 * @callsequence Simulator.callANDIR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callANDIR() {
		if (effectiveAddressCheck()) {
			index = and(index, getDecimalValue(memory[effectiveAddress]));
		}
	}

	/**
	 * @modulename callORIR
	 * @description c(IR)=c(IR) OR c(mem(effadd))
	 * @callsequence Simulator.callORIR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callORIR() {
		if (effectiveAddressCheck()) {
			index = or(index, getDecimalValue(memory[effectiveAddress]));
		}
	}

	/**
	 * @modulename callLANDIR
	 * @description c(IR)=c(IR) LAND c(mem(effadd))
	 * @callsequence Simulator.callLANDIR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callLANDIR() {
		if (effectiveAddressCheck()) {
			index = land(index, getDecimalValue(memory[effectiveAddress]));
		}
	}

	/**
	 * @modulename callLORIR
	 * @description c(IR)=c(IR) LOR c(mem(effadd))
	 * @callsequence Simulator.callLORIR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callLORIR() {
		if (effectiveAddressCheck()) {
			index = lor(index, getDecimalValue(memory[effectiveAddress]));
		}
	}

	/**
	 * @modulename callANDSR
	 * @description c(SR)=c(SR) AND c(mem(effadd))
	 * @callsequence Simulator.callANDSR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callANDSR() {
		if (effectiveAddressCheck()) {
			String statusString = hexToBinary(getHexString(and(
					getDecimalValue(binaryToHex(new String(status))),
					getDecimalValue(memory[effectiveAddress]))));

			status = statusString.toCharArray();
		}
	}

	/**
	 * @modulename callANDSR
	 * @description c(SR)=c(SR) OR c(mem(effadd))
	 * @callsequence Simulator.callANDSR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callORSR() {
		if (effectiveAddressCheck()) {
			String statusString = hexToBinary(getHexString(or(
					getDecimalValue(binaryToHex(new String(status))),
					getDecimalValue(memory[effectiveAddress]))));

			status = statusString.toCharArray();
		}
	}

	/**
	 * @modulename callABSIR
	 * @description c(IR)=|c(IR)|
	 * @callsequence Simulator.callABSIR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callABSIR() {
		int result = abs(index);

		if (result > 8388607 || result < -8388608) {
			JOptionPane.showMessageDialog(null,
					"ERROR: Multiplication over flow occurred at location "
							+ getHexString(location).substring(3)
							+ ". This operation will not be performed.");
			status[mulOverflow] = '1';
		} else {
			index = result;
		}
	}

	/**
	 * @modulename callSLAAC
	 * @description c(AC)=c(AC) [Shifted Left] effadd
	 * @callsequence Simulator.callSLAAC();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callSLAAC() {

		if (effectiveAddress > 24 || effectiveAddress < 0) {
			JOptionPane.showMessageDialog(null,
					"ERROR: Shift error occurred at location "
							+ getHexString(location).substring(3)
							+ ". This operation will not be performed.");
			status[shiftError] = '1';
		} else {
			accumulator = shiftLeft(accumulator, effectiveAddress);
		}

	}

	/**
	 * @modulename callSRAAC
	 * @description c(AC)=c(AC) [Right Shifted] effadd
	 * @callsequence Simulator.callSRAAC();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callSRAAC() {

		if (effectiveAddress > 24 || effectiveAddress < 0) {
			JOptionPane.showMessageDialog(null,
					"ERROR: Shift error occurred at location "
							+ getHexString(location).substring(3)
							+ ". This operation will not be performed.");
			status[shiftError] = '1';
		} else {
			accumulator = shiftRightArithmetic(accumulator, effectiveAddress);
		}

	}

	/**
	 * @modulename callSLLAC
	 * @description c(AC)=c(AC) [Shifted Left] effadd
	 * @callsequence Simulator.callSLLAC();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callSLLAC() {

		if (effectiveAddress > 24 || effectiveAddress < 0) {
			JOptionPane.showMessageDialog(null,
					"ERROR: Shift error occurred at location "
							+ getHexString(location).substring(3)
							+ ". This operation will not be performed.");
			status[shiftError] = '1';
		} else {
			accumulator = shiftLeft(accumulator, effectiveAddress);
		}

	}

	/**
	 * @modulename callSRLAC
	 * @description c(AC)=c(AC)[Right Shifted] effadd
	 * @callsequence Simulator.callSRLAC();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callSRLAC() {

		if (effectiveAddress > 24 || effectiveAddress < 0) {
			JOptionPane.showMessageDialog(null,
					"ERROR: Shift error occurred at location "
							+ getHexString(location).substring(3)
							+ ". This operation will not be performed.");
			status[shiftError] = '1';
		} else {
			accumulator = shiftRightLogical(accumulator, effectiveAddress);
		}

	}

	/**
	 * @modulename callRROTAC
	 * @description c(AC)=c(AC) [Right rotated] effadd
	 * @callsequence Simulator.callRROTAC();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callRROTAC() {

		if (effectiveAddress > 24 || effectiveAddress < 0) {
			JOptionPane.showMessageDialog(null,
					"ERROR: Rotate error occurred at location "
							+ getHexString(location).substring(3)
							+ ". This operation will not be performed.");
			status[rotateError] = '1';
		} else {
			accumulator = rightRotate(accumulator, effectiveAddress);
		}

	}

	/**
	 * @modulename callLROTAC
	 * @description c(AC)=c(AC) [left rotated] effadd
	 * @callsequence Simulator.callLROTAC();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callLROTAC() {

		if (effectiveAddress > 24 || effectiveAddress < 0) {
			JOptionPane.showMessageDialog(null,
					"ERROR: Rotate error occurred at location "
							+ getHexString(location).substring(3)
							+ ". This operation will not be performed.");
			status[rotateError] = '1';
		} else {
			accumulator = leftRotate(accumulator, effectiveAddress);
		}

	}

	/**
	 * @modulename callSLAIR
	 * @description c(IR)=c(IR) [Shifted Left] effadd
	 * @callsequence Simulator.callSLAIR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callSLAIR() {
		if (effectiveAddress > 24 || effectiveAddress < 0) {
			JOptionPane.showMessageDialog(null,
					"ERROR: Shift error occurred at location "
							+ getHexString(location).substring(3)
							+ ". This operation will not be performed.");
			status[shiftError] = '1';
		} else {
			index = shiftLeft(index, effectiveAddress);
		}

	}

	/**
	 * @modulename callSRAIR
	 * @description c(IR)=c(IR) [Right Shifted] effadd
	 * @callsequence Simulator.callSRAIR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callSRAIR() {
		if (effectiveAddress > 24 || effectiveAddress < 0) {
			JOptionPane.showMessageDialog(null,
					"ERROR: Shift error occurred at location "
							+ getHexString(location).substring(3)
							+ ". This operation will not be performed.");
			status[shiftError] = '1';
		} else {
			index = shiftRightArithmetic(index, effectiveAddress);
		}

	}

	/**
	 * @modulename callSLLIR
	 * @description c(IR)=c(IR) [Shifted Left] effadd
	 * @callsequence Simulator.callSLLIR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callSLLIR() {
		if (effectiveAddress > 24 || effectiveAddress < 0) {
			JOptionPane.showMessageDialog(null,
					"ERROR: Shift error occurred at location "
							+ getHexString(location).substring(3)
							+ ". This operation will not be performed.");
			status[shiftError] = '1';
		} else {
			index = shiftLeft(index, effectiveAddress);
		}

	}

	/**
	 * @modulename callSRLIR
	 * @description c(IR)=c(IR) [Right Shifted] effadd
	 * @callsequence Simulator.callSRLIR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callSRLIR() {
		if (effectiveAddress > 24 || effectiveAddress < 0) {
			JOptionPane.showMessageDialog(null,
					"ERROR: Shift error occurred at location "
							+ getHexString(location).substring(3)
							+ ". This operation will not be performed.");
			status[shiftError] = '1';
		} else {
			index = shiftRightLogical(index, effectiveAddress);
		}

	}

	/**
	 * @modulename callRROTIR
	 * @description c(IR)=c(IR) [Right rotated] effadd
	 * @callsequence Simulator.callRROTIR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callRROTIR() {
		if (effectiveAddress > 24 || effectiveAddress < 0) {
			JOptionPane.showMessageDialog(null,
					"ERROR: Rotate error occurred at location "
							+ getHexString(location).substring(3)
							+ ". This operation will not be performed.");
			status[rotateError] = '1';
		} else {
			index = rightRotate(index, effectiveAddress);
		}

	}

	/**
	 * @modulename callLROTIR
	 * @description c(IR)=c(IR) [left rotated] effadd
	 * @callsequence Simulator.callRROTIR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callLROTIR() {
		if (effectiveAddress > 24 || effectiveAddress < 0) {
			JOptionPane.showMessageDialog(null,
					"ERROR: Rotate error occurred at location "
							+ getHexString(location).substring(3)
							+ ". This operation will not be performed.");
			status[rotateError] = '1';
		} else {
			index = leftRotate(index, effectiveAddress);
		}

	}

	/**
	 * @modulename callLDNAC
	 * @description (-1)*AC c(-AC)=c(memory(effadd))
	 * @callsequence Simulator.callLDNAC();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callLDNAC() {
		if (effectiveAddressCheck()) {
			int result = getDecimalValue(memory[effectiveAddress]) * -1;

			if (result > 8388607 || result < -8388608) {
				JOptionPane.showMessageDialog(null,
						"ERROR: Multiplication over flow occurred at location "
								+ getHexString(location).substring(3)
								+ ". This operation will not be performed.");
				status[mulOverflow] = '1';
			} else {
				accumulator = result;
			}
		}
	}

	/**
	 * @modulename callHALT
	 * @description halts module execution
	 * @callsequence Simulator.callHALT();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callHALT() {
		// halt!
	}

	/**
	 * @modulename callJMPPRLT
	 * @description If c(PR)<0 LC=effadd
	 * @callsequence Simulator.callJMPPRLT();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callJMPPRLT() {
		if (parameterListAddress < 0) {
			location = effectiveAddress;
			status[jump] = '1';

		}
	}

	/**
	 * @modulename callJMPSRGT
	 * @description If c(SR)>0 LC=effadd
	 * @callsequence Simulator.callJMPSRGT();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callJMPSRGT() {

		String statusString = new String(status);
		String signBit = statusString.substring(0, 1);

		while (statusString.length() < 24) {
			statusString = signBit + statusString;
		}

		if (getDecimalValue(binaryToHex(statusString)) > 0) {
			location = effectiveAddress;
			status[jump] = '1';
		}
	}

	/**
	 * @modulename callJMPSREQ
	 * @description If c(SR)=0 LC=effadd
	 * @callsequence Simulator.callJMPSREQ();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callJMPSREQ() {
		String statusString = new String(status);
		String signBit = statusString.substring(0, 1);

		while (statusString.length() < 24) {
			statusString = signBit + statusString;
		}

		if (getDecimalValue(binaryToHex(statusString)) == 0) {
			location = effectiveAddress;
			status[jump] = '1';
		}
	}

	/**
	 * @modulename callJMPSRLT
	 * @description c(SR)<0 LC=effadd
	 * @callsequence Simulator.callJMPSRLT();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callJMPSRLT() {
		String statusString = new String(status);
		String signBit = statusString.substring(0, 1);

		while (statusString.length() < 24) {
			statusString = signBit + statusString;
		}

		if (getDecimalValue(binaryToHex(statusString)) < 0) {
			location = effectiveAddress;
			status[jump] = '1';
		}
	}

	/**
	 * @modulename callJMP
	 * @description LC=effadd
	 * @callsequence Simulator.callJMP();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callJMP() {
		location = effectiveAddress;
		status[jump] = '1';
	}

	/**
	 * @modulename callJMPACGT
	 * @description If AC = If c(AC)=0 LC=effadd
	 * @callsequence Simulator.callJMPACGT();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callJMPACGT() {
		if (accumulator > 0) {
			location = effectiveAddress;
			status[jump] = '1';
		}
	}

	/**
	 * @modulename callJMPACEQ
	 * @description If AC = If c(AC)=0 LC=effadd
	 * @callsequence Simulator.callJMPACEQ();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callJMPACEQ() {
		if (accumulator == 0) {
			location = effectiveAddress;
			status[jump] = '1';
		}
	}

	/**
	 * @modulename callJMPACLT
	 * @description If c(AC)<0 LC=effadd
	 * @callsequence Simulator.callJMPACLT();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callJMPACLT() {
		if (accumulator < 0) {
			location = effectiveAddress;
			status[jump] = '1';
		}
	}

	/**
	 * @modulename callJMPACLT
	 * @description If c(AC)<0 LC=effadd
	 * @callsequence Simulator.callJMPACLT();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callJMPIRGT() {
		if (index > 0) {
			location = effectiveAddress;
			status[jump] = '1';
		}
	}

	/**
	 * @modulename callJMPIREQ
	 * @description If c(IR)=0 LC=effadd
	 * @callsequence Simulator.callJMPIREQ();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callJMPIREQ() {
		if (index == 0) {

			location = effectiveAddress;
			status[jump] = '1';
		}
	}

	/**
	 * @modulename callJMPIRLT
	 * @description If c(IR)<0 LC=effadd
	 * @callsequence Simulator.callJMPIRLT();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callJMPIRLT() {
		if (index < 0) {
			location = effectiveAddress;
			status[jump] = '1';
		}
	}

	/**
	 * @modulename callDISPLAY
	 * @description If 0 Display All registers, if 1 Display LC and c(mem(LC)),
	 *              if 2 Display active memory locations in a matrix format
	 * @callsequence Simulator.callJMPIRLT();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callDISPLAY() {
		switch (Integer.parseInt(parsedInstruction[address], 2)) {
		case 0:
			informationDump("Display 0: See output log for display. Click \"OK\" to continue.");
			break;
		case 1:
			Main2.appendDebugText("Location Counter Register:\t"
					+ getHexString(location).substring(3));
			displayMemory(location, location);
			JOptionPane
					.showMessageDialog(null,
							"Display 1: See output log for display. Click \"OK\" to continue.");
			break;
		case 2:
			displayMemory(LoadFile.returnLoadAddress(), LoadFile
					.returnLoadAddress()
					+ LoadFile.returnModuleLength() - 1);

			JOptionPane
					.showMessageDialog(null,
							"Display 2: See output log for display. Click \"OK\" to continue.");
			break;
		default:
			break;
		}
	}

	/**
	 * @modulename callREADNUM
	 * @description Reads a number from keybord store results into
	 *              c(memory(effadd))
	 * @callsequence Simulator.callREADNUM();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callREADNUM() {
		if (effectiveAddressCheck()) {
			// get number from keyboard
			int num = 0;

			do {
				String tempString = JOptionPane.showInputDialog(null,
						"Enter a decimal number between -2^23 and 2^23 - 1:");
				try{
				num = Integer.parseInt(tempString);
				}
				catch(NumberFormatException e){
					num=-8388610;
				}
				if (num > 8388607 || num < -8388608) {
					JOptionPane
							.showMessageDialog(null,
									"User Error: The number must be between between -2^23 and 2^23 - 1.");
				}
			} while (num > 8388607 || num < -8388608);

			// store number at effAddr
			if (effectiveAddress < LoadFile.returnLoadAddress()
					|| effectiveAddress > (LoadFile.returnLoadAddress()
							+ LoadFile.returnModuleLength() - 1)) {
				// HALT 98
				parsedInstruction[opcode] = "101010";
				parsedInstruction[address] = "00001100010";
			} else {
				memory[effectiveAddress] = getHexString(num);
			}
		}
	}

	/**
	 * @modulename callREADSTR
	 * @description Reads a string from keybord store results into
	 *              c(memory(effadd))
	 * @callsequence Simulator.callREADSTR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	// 111001 39 READ-STR REF-ALL Read string from keybord place starting in
	// reference Store results into c(memory(effadd))
	public static void callREADSTR() {
		if (effectiveAddressCheck()) {
			String str = new String();

			do {
				str = JOptionPane.showInputDialog(null,
						"Enter a character string up to three characters:");
				if (str.length() > 3) {
					JOptionPane
							.showMessageDialog(null,
									"User Error: The string may not contain more than three characters.");
				}
			} while (str.length() > 3);

			// add spaces
			while (str.length() < 3) {
				str = str + " ";
			}

			// store number at effAddr
			if (effectiveAddress < LoadFile.returnLoadAddress()
					|| effectiveAddress > (LoadFile.returnLoadAddress()
							+ LoadFile.returnModuleLength() - 1)) {
				// HALT 98
				parsedInstruction[opcode] = "101010";
				parsedInstruction[address] = "00001100010";
			} else {

				memory[effectiveAddress] = asciiString(str);
			}
		}
	}

	/**
	 * @modulename callWRITENUM
	 * @description Write number from memory reference
	 *              """WRITE"" from c(memory(effadd))"
	 * @callsequence Simulator.callWRITENUM();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callWRITENUM() {
		if (effectiveAddressCheck()) {

			memory[location] = memory[effectiveAddress];

		}
	}

	/**
	 * @modulename callWRITESTR
	 * @description Write string (2) from memory reference
	 *              """WRITE"" from c(memory(effadd))"
	 * @callsequence Simulator.callWRITESTR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callWRITESTR() {
		if (effectiveAddressCheck()) {
			memory[location] = memory[effectiveAddress];
		}
	}

	/**
	 * @modulename callLDACADR
	 * @description c(AC)=effadd
	 * @callsequence Simulator.callLDACADR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callLDACADR() {
		accumulator = effectiveAddress;
	}

	/**
	 * @modulename callLDIRADR
	 * @description c(IR)=effadd
	 * @callsequence Simulator.callLDIRADR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callLDIRADR() {
		index = effectiveAddress;
	}

	/**
	 * @modulename callLDBRADR
	 * @description c(BR)=effadd
	 * @callsequence Simulator.callLDBRADR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callLDBRADR() {
		base = effectiveAddress;
	}

	/**
	 * @modulename callLDPR
	 * @description (PR)=c(memory(effadd))
	 * @callsequence Simulator.callLDPR();
	 * @inparam none
	 * @outparam none
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/18/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/18/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static void callLDPR() {
		if (effectiveAddressCheck()) {
			parameterListAddress = getDecimalValue(memory[effectiveAddress]);
		}
	}

	/**
	 * @modulename and
	 * @description this method ANDs two integers
	 * @callsequence and(int int1, int int2)
	 * @inparam (int) int1: first integer to be ANDed, (int) int2: second
	 *          integer to be ANDed
	 * @outparam (int) result of the AND
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/19/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/19/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static int and(int int1, int int2) {
		String result = new String();

		// convert to binary
		String int1String = hexToBinary(getHexString(int1));
		String int2String = hexToBinary(getHexString(int2));

		// and each bit
		for (int i = 0; i < 24; i++) {
			if (int1String.charAt(i) == '1' && int2String.charAt(i) == '1') {
				result = result + "1";
			} else {
				result = result + "0";
			}
		}

		// return the result
		return getDecimalValue(binaryToHex(result));
	}

	/**
	 * @modulename or
	 * @description this method ORs two integers
	 * @callsequence and(int int1, int int2)
	 * @inparam (int) int1: first integer to be ORed, (int) int2: second integer
	 *          to be ORed
	 * @outparam (int) result of the OR
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/19/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/19/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static int or(int int1, int int2) {
		String result = new String();

		// convert to binary
		String int1String = hexToBinary(getHexString(int1));
		String int2String = hexToBinary(getHexString(int2));

		// and each bit
		for (int i = 0; i < 24; i++) {
			if (int1String.charAt(i) == '1' || int2String.charAt(i) == '1') {
				result = result + "1";
			} else {
				result = result + "0";
			}
		}

		// return the result
		return getDecimalValue(binaryToHex(result));
	}

	/**
	 * @modulename land
	 * @description this method logical ANDs two integers
	 * @callsequence and(int int1, int int2)
	 * @inparam (int) int1: first integer to be logical ANDed, (int) int2:
	 *          second integer to be logical ANDed
	 * @outparam (int) result of the logical AND
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/19/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/19/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static int land(int int1, int int2) {
		if (int1 == 1 && int2 == 1) {
			return 1;
		}
		return 0;
	}

	/**
	 * @modulename lor
	 * @description this method logical ORs two integers
	 * @callsequence and(int int1, int int2)
	 * @inparam (int) int1: first integer to be logical ORed, (int) int2: second
	 *          integer to be logical ORed
	 * @outparam (int) result of the logical OR
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/19/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/19/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static int lor(int int1, int int2) {
		if (int1 == 1 || int2 == 1) {
			return 1;
		}
		return 0;
	}

	/**
	 * @modulename abs
	 * @description this method find the absolute value of a number
	 * @callsequence abs(int int1)
	 * @inparam (int) int1: integer to be absoluted
	 * @outparam (int) result of the logical OR
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/19/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/19/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static int abs(int i) {
		if (i >= 0) {
			return i;
		}

		return i * -1;
	}

	/**
	 * @modulename shiftRightArithmetic
	 * @description this method performs an arithmetic shift on an integer
	 * @callsequence shiftRightArithmetic(int int1, int shift)
	 * @inparam (int) int1: integer to be shifted, (int) shift: the number of
	 *          places to shift
	 * @outparam (int) result of the shift
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/19/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/19/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static int shiftRightArithmetic(int int1, int shift) {

		String binary = hexToBinary(getHexString(int1));

		Character signBit = binary.charAt(0);

		for (int i = 0; i < shift; i++) {
			binary = signBit + binary;
			binary = binary.substring(0, binary.length() - 1);
		}

		return getDecimalValue(binaryToHex(binary));
	}

	/**
	 * @modulename shiftRightLogical
	 * @description this method performs an logical shift on an integer
	 * @callsequence shiftshiftRightLogical(int int1, int shift)
	 * @inparam (int) int1: integer to be shifted, (int) shift: the number of
	 *          places to shift
	 * @outparam (int) result of the shift
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/19/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/19/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static int shiftRightLogical(int int1, int shift) {
		String binary = hexToBinary(getHexString(int1));

		for (int i = 0; i < shift; i++) {
			binary = "0" + binary;
			binary = binary.substring(0, binary.length() - 1);
		}

		return getDecimalValue(binaryToHex(binary));
	}

	/**
	 * @modulename shiftLeft
	 * @description this method performs a shift on an integer
	 * @callsequence shiftLeft(int int1, int shift)
	 * @inparam (int) int1: integer to be shifted, (int) shift: the number of
	 *          places to shift
	 * @outparam (int) result of the shift
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/19/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/19/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static int shiftLeft(int int1, int shift) {
		String binary = hexToBinary(getHexString(int1));

		for (int i = 0; i < shift; i++) {
			binary = binary + "0";
			binary = binary.substring(1);
		}

		return getDecimalValue(binaryToHex(binary));
	}

	/**
	 * @modulename rightRotate
	 * @description this method performs a right rotate on an integer
	 * @callsequence rightRotate(int int1, int rotate)
	 * @inparam (int) int1: integer to be shifted, (int) rotate: the number of
	 *          places to rotate
	 * @outparam (int) result of the rotate
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/19/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/19/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static int rightRotate(int int1, int rotate) {

		String binary = hexToBinary(getHexString(int1));

		for (int i = 0; i < rotate; i++) {
			binary = binary.charAt(binary.length() - 1)
					+ binary.substring(0, binary.length() - 1);
		}

		return getDecimalValue(binaryToHex(binary));
	}

	/**
	 * @modulename leftRotate
	 * @description this method performs a left rotate on an integer
	 * @callsequence leftRotate(int int1, int rotate)
	 * @inparam (int) int1: integer to be shifted, (int) rotate: the number of
	 *          places to rotate
	 * @outparam (int) result of the rotate
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/19/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/19/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static int leftRotate(int int1, int rotate) {
		String binary = hexToBinary(getHexString(int1));

		for (int i = 0; i < rotate; i++) {
			binary = binary.substring(1, binary.length()) + binary.charAt(0);
		}

		return getDecimalValue(binaryToHex(binary));
	}

	/**
	 * @modulename asciiString
	 * @description This module returns the ascii string of up to 3 characters.
	 * @callsequence asciiString(chrString);
	 * @inparam (String) chrString, this is the character string
	 * @outparam (String), this is the ascii string
	 * @errorstested See JUnit test cases
	 * @errorsgenerated See errata report
	 * @author Nick Lister
	 * @createdate 11/19/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Nick, 11/19/09, module created
	 *         </ul>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static String asciiString(String chrString) {
		// add spaces for char string with less than three chars
		while (chrString.length() < 3) {
			chrString = chrString + " ";
		}

		// get the ASCII hex string for the characters
		String asciiString = Integer.toHexString(chrString.charAt(0))
				+ Integer.toHexString(chrString.charAt(1))
				+ Integer.toHexString(chrString.charAt(2));

		// return the value
		return asciiString;
	}

	public static int getDecimalValue(String hex) {

		while (hex.length() > 6) {
			hex = hex.substring(1);
		}

		int value = Integer.parseInt(hex, 16);

		if (value >= 0 && value <= 8388607) {
			return value;
		}

		return value - 16777216;
	}

	public static String getHexString(int value) {
		String hex = Integer.toHexString(value);

		while (hex.length() > 6) {
			hex = hex.substring(1);
		}

		while (hex.length() < 6) {
			hex = "0" + hex;
		}

		return hex.toUpperCase();
	}

	public static String binaryToHex(String binary) {
		String hex = "";

		while (binary.length() < 24) {
			binary = "0" + binary;
		}

		while (binary.length() > 24) {
			binary = binary.substring(1);
		}

		while (binary.length() > 0) {
			String halfByte = Integer.toHexString(Integer.parseInt(binary
					.substring(0, 4), 2));
			binary = binary.substring(4);

			hex = hex + halfByte;
		}

		return hex;
	}

	public static String hexToBinary(String hex) {
		String binary = "";

		while (hex.length() < 6) {
			hex = "0" + hex;
		}

		while (hex.length() > 6) {
			hex = hex.substring(1);
		}

		while (hex.length() > 0) {
			String halfByte = Integer.toBinaryString(Integer.parseInt(hex
					.substring(0, 1), 16));
			hex = hex.substring(1);

			while (halfByte.length() < 4) {
				halfByte = "0" + halfByte;
			}

			binary = binary + halfByte;
		}

		return binary;
	}
}